import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

class MyFrame extends JFrame
   implements ActionListener
{
	public MyFrame()
    {
	    setTitle("Fortune telling");
	    setSize(300, 200);
	    setLocation(100,100);
        addWindowListener(new WindowAdapter()
        {
			public void windowClosing(WindowEvent e)
            {  System.exit(0);
            }
         });

		 String[] array =
		 {  "CAPRICORN","AQUARIUS","PISCES","ARIES","TAURUS","GEMINI","CANCER","LEO","VIRGO","LIBRA","SCORPIO",
                    "SAGITTARIUS"
		 };

		 //set JComboBox
		 cb = new JComboBox(array);
		 cb.setEditable(true);

		 //add scroll
		 JScrollPane scrollPane = new JScrollPane(cb);
		 JPanel p = new JPanel();
		 p.add(scrollPane);

		 //put the swing into south
		 cb.addActionListener(this);
		 getContentPane().add(p, "South");

		 //display the control in center
		 panel = new MyPanel();
		 getContentPane().add(panel, "Center");

		 // enter the add or delete in the north
		 JPanel btPane = new JPanel();
		 btAdd = new JButton("Add horoscope");
		 btRemove = new JButton("Remove horoscope");
		 btAdd.addActionListener(this);
		 btRemove.addActionListener(this);
		 btPane.add(btAdd);
		 btPane.add(btRemove);
		 getContentPane().add(btPane, "North");
	}

    public void actionPerformed(ActionEvent evt)
    {
	    JComponent source = (JComponent)evt.getSource();

	    if (source == cb)
	    {
			String item = (String)((JComboBox)source).getSelectedItem();
			panel.setMsg(item);
			panel.repaint();
		}
		else if (source == btAdd)
		//add project
		{
			cb.addItem("strange horoscope");
		}
		else if (source == btRemove)
		//delete project
		{
			cb.removeItem("strange horoscope");
		}
    }

	private JButton btAdd;
	private JButton btRemove;
   	private MyPanel panel;
   	JComboBox cb;
}

class MyPanel extends JPanel
{
	public MyPanel()
	{
		szShowMsg = "";
	}

	public void setMsg(String szMsg)
	{
		szShowMsg = szMsg;
	}

	// draw the information 
	public void paintComponent(Graphics g)
    {
 	    super.paintComponent(g);
		g.drawString(szShowMsg, 20, 20);
   }

   private String szShowMsg;

}

public class Mini
{
	public static void main(String[] args)
    {
                String input;
                input=JOptionPane.showInputDialog("Please enter your name");
		JFrame frame = new MyFrame();
                frame.setVisible(true);
    }
}
